package com.neuedu.curd.service;

import com.neuedu.curd.dao.UserDao;
import com.neuedu.curd.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目：springmvc-java4
 * 创建时间：  2022-03-25   8:38
 * 作者 :jshand
 * 描述 :
 */
@Service
public class UserService {


    @Autowired
    UserDao userDao;


    /**
     * 查询列表
     * @return
     */
    public List<User> list(){
        List<User> users = userDao.selectList();
        return users;
    }


    /**
     * 添加
     * @param user
     * @return
     */
    public boolean save(User user) {
        int count = userDao.insert(user);
        return count>0;
    }

    public User queryById(Integer id) {

        return userDao.selectById(id);
    }

    public boolean update(User user) {
        int count = userDao.update(user);
        return count>0;
    }

    public boolean deleteById(Integer id) {
        return userDao.deleteById(id)>0;
    }
}
